package com.Jack.Test;

import java.util.ArrayList;
import java.util.List;

import com.Jack.bean.Receipt;
import com.Jack.bean.ReceiptDetail;

public class Main2 {
	public static void main(String[] args) {
		List<Receipt> list1 = new ArrayList<Receipt>();
		
		Receipt Receipt1 = new Receipt();
		Receipt1.setSerial("1");
		Receipt1.setReceiptkey("T00001");
		Receipt1.setStatus("ok1");
		Receipt1.setSku("E16441001");
		
		Receipt Receipt2 = new Receipt();
		Receipt2.setSerial("1");
		Receipt2.setReceiptkey("T00001");
		Receipt2.setStatus("ok2");
		Receipt2.setSku("E16441002");
		
		Receipt Receipt3 = new Receipt();
		Receipt3.setSerial("3");
		Receipt3.setReceiptkey("T00003");
		Receipt3.setStatus("ok3");
		Receipt3.setSku("E16441003");
		
		Receipt Receipt4 = new Receipt();
		Receipt4.setSerial("4");
		Receipt4.setReceiptkey("T00004");
		Receipt4.setStatus("ok4");
		Receipt4.setSku("E16441003");
		
		list1.add(Receipt1);
		list1.add(Receipt2);
		list1.add(Receipt3);
		list1.add(Receipt4);
		
		

		
		/*
		for (int i = 0; i < list2.size(); i++) {
			System.out.println(list2.get(i).getSku());			
		}
		*/
		
		String str="";
		StringBuffer sb =new StringBuffer();
		for (int i = 0; i < list1.size(); i++) {
			if(i == 0){
				str = list1.get(i).getSerial();
			}
			if(str == list1.get(i).getSerial()){
				sb.append(list1.get(i).getSku());
			}else{
				System.out.println(sb.toString());
				str = list1.get(i).getSerial();
				sb =new StringBuffer();
				sb.append("表头数据:"+list1.get(i).getSerial()+"," + list1.get(i).getReceiptkey()+ " ");
			}
			
		}
		
		/*for (int i = 0; i < list1.size(); i++) {
			StringBuffer sb =new StringBuffer();
			sb.append("表头数据:"+list1.get(i).getSerial()+"," + list1.get(i).getReceiptkey()+ " ");
			int ij = 0;
			try {
				ij = list1.get(i).getReceiptDetails().size();				
			} catch (Exception e) {
				ij = 0;
			}
			for (int j = 0; j < ij; j++) {
				String str = list1.get(i).getReceiptDetails().get(j).getSku();
				sb.append(str+",");
			}
			System.out.println(sb.toString());
		}*/
		
	}
	
	
	
}

